def options(opt):
  pass

def configure(conf):
  pass


def build_one(bld, name, libraries = ''):
  __sources = '%s_impl.cpp %s_serv.cpp' % (name, name)

  bld.program(
    source = __sources,
    target = 'juba'+name,
    includes = '. ../framework',
    use = 'jubatus_framework jubacommon_mprpc jubatus_%s %s' % (name, libraries)
    )
  if bld.env.HAVE_ZOOKEEPER_H:
    bld.program(
      source = '%s_keeper.cpp ' % name,
      target = 'juba%s_keeper' % name,
      includes = '. ../framework',
      use = 'PFICOMMON jubatus_framework jubacommon_mprpc'
      )
  bld.program(
    features = 'gtest',
    source = '%s_test.cpp' % name,
    target = '%s_test' % name,
    includes = '. ../framework',
    use = 'PFICOMMON MSGPACK jubacommon_mprpc',
    )


def build(bld):

  #new classifier
  build_one(bld, "classifier", 'jubaconverter jubastorage')

  #new regression
  build_one(bld, "regression", 'jubaconverter jubastorage')

  #new recommender
  build_one(bld, "recommender", 'jubaconverter jubastorage')

  build_one(bld, "stat")

  build_one(bld, "graph")

  n = bld.path.get_bld().make_node('test_input')
  n.mkdir()
  bld(rule = 'cp ${SRC} ${TGT}',
      source = bld.path.ant_glob('test_input/*'),
      target = n)

  bld.install_files('${PREFIX}/include/jubatus/client', [
      'classifier_types.hpp',
      'classifier_client.hpp',
      'regression_types.hpp',
      'regression_client.hpp',
      'recommender_types.hpp',
      'recommender_client.hpp',
      'stat_types.hpp',
      'stat_client.hpp',
      'graph_types.hpp',
      'graph_client.hpp',
      ])

  bld.install_files('${PREFIX}/share/jubatus/', [
      'classifier.idl',
      'regression.idl',
      'recommender.idl',
      'stat.idl',
      'graph.idl',
      ])
